package com.reggie.common;

public class ReggieContext {
    /**
     * 使用threadLocal存储登录用户的id，每次会话就是一个线程，threadLocal生效范围为当前线程
     * 注意：要手动删除存储的内容，不然会导致内存泄漏
     */
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static Long get() {
        return threadLocal.get();
    }

    public static void set(Long id) {
        threadLocal.set(id);
    }

    public static void remove() {
        threadLocal.remove();
    }
}
